package com.dingreading.cloud.gateway.service.impl;

import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.gateway.entity.AdminRoleStaff;
import com.dingreading.cloud.gateway.entity.table.AdminRoleStaffTableDef;
import com.dingreading.cloud.gateway.mapper.AdminRoleStaffMapper;
import com.dingreading.cloud.gateway.service.AdminRoleStaffService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Service
public class AdminRoleStaffServiceImpl extends BaseServiceImpl<AdminRoleStaffMapper, AdminRoleStaff, AdminRoleStaffTableDef> implements AdminRoleStaffService {

    @Override
    protected AdminRoleStaffTableDef getTable() {
        return AdminRoleStaffTableDef.adminRoleStaff;
    }


    @Override
    public List<String> identifyListByStaffUid(String staffUid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.headStaffUid.eq(staffUid));
        List<AdminRoleStaff> list = getMapper().selectListWithRelationsByQuery(wrapper);
        if (CollectionUtils.isNotEmpty(list))
            return list.stream().map(AdminRoleStaff::getIdentify).filter(StringUtils::isNotBlank).collect(Collectors.toList());
        return null;
    }
}
